import React from 'react'
import Cookies from "react-cookies";

const AuthRouter = (props) => {

    if (props.auth) {
        // 获取登录信息
        let LoginAuth = Cookies.load('LoginAuth') ? Cookies.load('LoginAuth') : {}

        if (!LoginAuth || JSON.stringify(LoginAuth) === '{}') {
            React.$Vant.Toast({
                type: 'error',
                message: '请先登录',
            })
            return (
                <React.$Router.Navigate to='/business/base/login' />
            )
        }
        return <>{props.component}</>;
    } else {
        return <>{props.component}</>;
    }
}

export default AuthRouter